<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>登陆页面</title>
	<link rel="stylesheet" href="../../front/css/login.css">
</head>
<body>
	<div class="dress">
		<img src="../../front/images/login01.jpg" width="300">
	</div>
	<div class="login">
		<h1>欢迎登陆&nbsp;&nbsp;<i>Tomorrow</i>博客</h1>
		<p class="h1p1">Tomorrow will be better.</p>
		<p class="h1p2">Tomorrow there will be good things waiting for you.</p>
		<p class="h1p3">Tomorrow Blog</p>
		<form action="/user/front/login" method="post" id="loginForm" onsubmit="return false;">
			<div class="userName">
				<label>用户名</label>
				<input type="text" name="userName" class="inputAni">
			</div>
			<div class="userPassword">
				<label>密&nbsp;&nbsp;码</label>
				<input type="password" name="userPassword" class="inputAni">
			</div>
			<input type="submit" value="登录" class="submit" id="loginButton"/>
			<input type="reset" value="重置" class="reset">
			<a href="/front/register.jsp" class="register">没有账号？点击注册!</a>
		</form>
	</div>



	<script src="../../front/js/jquery-1.9.1.min.js"></script>


	<script type="text/javascript">

        $(function () {
            $('#loginForm').submit(function () {
                var postData = $("#loginForm").serialize(); //序列化表单，后台可正常通过post方法获取数据
                console.log(postData)
                $.ajax({
                    type: "POST",
                    url: "/user/front/login",
                    data: postData,
                    beforeSend: function() {
                        $("#loginButton").attr("disabled", true);//提交表单前的处理，防止用户多次点击【登陆】，重复提交表单
                    },
                    success: function(data) {

                        if (data.success) {
                            alert('登录成功');
                            window.location.href = '../../frontIndex';
                        } else {
                            $("#loginButton").attr("disabled", false);
                            $("#loginButton").val("登陆");
                            alert("用户或密码错误！");
                        }
                    }
                });

            });

        });


	</script>



</body>



</html>